from pydantic import BaseModel
from datetime import datetime
from typing import Optional
from app.models.flight import FlightStatus

class FlightBase(BaseModel):
    flight_number: str
    airline: str
    departure_city: str
    arrival_city: str
    departure_time: datetime
    arrival_time: datetime
    departure_airport: str
    arrival_airport: str
    price: float
    total_seats: int
    available_seats: int
    status: FlightStatus = FlightStatus.scheduled

class FlightCreate(FlightBase):
    pass

class FlightUpdate(BaseModel):
    flight_number: Optional[str] = None
    airline: Optional[str] = None
    departure_city: Optional[str] = None
    arrival_city: Optional[str] = None
    departure_time: Optional[datetime] = None
    arrival_time: Optional[datetime] = None
    departure_airport: Optional[str] = None
    arrival_airport: Optional[str] = None
    price: Optional[float] = None
    total_seats: Optional[int] = None
    available_seats: Optional[int] = None
    status: Optional[FlightStatus] = None

class FlightResponse(FlightBase):
    id: int
    created_at: datetime
    updated_at: Optional[datetime] = None

    class Config:
        from_attributes = True

class FlightSearchParams(BaseModel):
    departure_city: Optional[str] = None
    arrival_city: Optional[str] = None
    departure_date: Optional[datetime] = None
    airline: Optional[str] = None